﻿// -----------------------------------------------------------------------
// <copyright file="SummonTest.cs" company="Chalmers">
// 
// Copyright (c) 2012 Chalmers University of Technology
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in 
// the Software without restriction, including without limitation the rights to 
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 
// of the Software, and to permit persons to whom the Software is furnished to do 
// so, subject to the following conditions:

// The above copyright notice and this permission notice shall be included in all 
// copies or substantial portions of the Software.

// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
// DEALINGS IN THE SOFTWARE.
// </copyright>
// -----------------------------------------------------------------------

using System.Collections.Generic;
using Chalmers.Summon;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace SummonApiTest
{
    
    
    /// <summary>
    ///This is a test class for SummonTest and is intended
    ///to contain all SummonTest Unit Tests
    ///</summary>
    [TestClass()]
    public class SummonTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        ///A test for SummonizeString
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Chalmers.Summon.dll")]
        public void SummonizeStringTest()
        {
            Summon_Accessor target = new Summon_Accessor(); // TODO: Initialize to an appropriate value
            string queryString = "c&b&a"; // TODO: Initialize to an appropriate value
            string expected = "a&b&c"; // TODO: Initialize to an appropriate value
            string actual;
            actual = target.SummonizeString(queryString);
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ComputeSortedQueryString
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Chalmers.Summon.dll")]
        public void ComputeSortedQueryStringTest()
        {
            Summon_Accessor target = new Summon_Accessor(); // TODO: Initialize to an appropriate value
            
            Dictionary<string, string> temp = new Dictionary<string, string>();
            temp.Add("s.q", "tintin");
            temp.Add("s.ho", "true");

            target.SummonQuery = temp;

            string expected = "s.ho=true&s.q=tintin"; // TODO: Initialize to an appropriate value
            
            string actual;
            actual = target.ComputeSortedQueryString();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetDateTime
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Chalmers.Summon.dll")]
        public void GetDateTimeTest()
        {
            Summon_Accessor target = new Summon_Accessor(); // TODO: Initialize to an appropriate value

            TimeZone localTimeZone = TimeZone.CurrentTimeZone;

            string expected = localTimeZone.IsDaylightSavingTime(DateTime.Now) ? "CEST" : "CET";

            string actual;
            actual = target.GetDateTime();
            Assert.IsTrue(actual.Contains(expected));
        }

        /*
        /// <summary>
        ///A test for GetResultType
        ///</summary>
        [TestMethod()]
        [DeploymentItem("Chalmers.Summon.dll")]
        public void GetResultTypeTest()
        {
            Summon_Accessor target = new Summon_Accessor(); // TODO: Initialize to an appropriate value
            Summon.ResultType resultFormat = Chalmers.Summon.Summon.ResultType.Xml; // TODO: Initialize to an appropriate value
            string expected = "application/xml"; // TODO: Initialize to an appropriate value
            string actual;
            actual = target.GetResultType(resultFormat);
            Assert.AreEqual(expected, actual);
        }
        */
    }
}
